import React from 'react';
import Relay from "react-relay";
import MsLoginMutation from "./login/mutation/MsLoginMutation.js"
import EventManager from './util/EventManager.js'
import Main from './ms/main/Main.js'
import Login from './login/Login.js'
import {hashHistory} from 'react-router'
export default class Hello extends React.Component {

    constructor() {
        super();
        this.state = {
            islogin: true
        }
    }

    componentWillMount() {
        EventManager.on('islogin', (param) => {
            this.setState({
                islogin: param
            });
        })
        let uid = sessionStorage.getItem('msUid');
        let token = sessionStorage.getItem('msToken');

        if ((token == null || token == 'null') && (uid == null || uid == 'null')) {
            EventManager.emitter('islogin', false);
        } else {
            EventManager.emitter('islogin', true);
        }


    }


    render() {

        return (
            <div>
                {
                    this.state.islogin
                        ?
                        <Main />
                        :
                        <Login />
                }

            </div>
        );
    }
}